/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2016 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>
*/
#ifndef OSGEARTH_ANNOTATION_IMAGE_NODE_H
#define OSGEARTH_ANNOTATION_IMAGE_NODE_H 1

#include <osgEarthAnnotation/GeoPositionNode>
#include <osgEarthSymbology/Style>
#include <osgEarth/Containers>
#include <osg/Image>
#include <osgText/String>

namespace osgEarth
{ 
    class MapNode;
}
    
namespace osgEarth { namespace Annotation
{	
    using namespace osgEarth;
    using namespace osgEarth::Symbology;

    /** 
     * TrackNode is a movable, single-point entity represented by an icon,
     * optional placeable text labels, and optional localized geometry.
     *
     * NOTE. TrackNode does not automatically support terrain clamping. This is
     * because its intention is for use as a trackable entity marker, and 
     * presumably the entity itself will be responsible for its own absolute
     * positioning (and clamping, if applicable).
     */
    class ImageNode : public GeoPositionNode
    {
    public:
        META_AnnotationNode(osgEarthAnnotation, ImageNode);

        /**
         * Constructs a new track node
         * @param mapNode     Map node under which this track will live
         * @param position    Initial position
         * @param image       Icon image to use
         * @param fieldSchema Schema for track label fields
         */
        ImageNode(MapNode* mapNode,const GeoPoint& position,osg::Image* image,double scale,double head = 0.0);
    public:
        virtual void setPriority(float value);
		void setHeading(double heading);
		double getHeading()const { return heading; }
    protected:

        virtual ~ImageNode() { }

        Style             _style;
        class osg::Geode* _geode;
		osg::Image* image = nullptr;
		osg::Geometry* imageGeom = nullptr;
		double scale = 0.0;
		double heading = 0.0;

        void init(double scale,double head);
    protected: // AnnotationNode override
        virtual bool supportsRenderBinDetails() const { return false; }
    private:
        // required by META_Node, but this object is not cloneable
        ImageNode() { }
        ImageNode(const ImageNode& rhs, const osg::CopyOp& op =osg::CopyOp::DEEP_COPY_ALL) { }

        void updateLayoutData();

    };

} } // namespace osgEarth::Annotation

#endif //OSGEARTH_ANNOTATION_TRACK_NODE_H
